#!/bin/bash
if [ "$1" == "" ]; then
  echo "Usage: hashpass <username>"
  exit 1
fi

  echo -n "(current) UNIX password: "
  stty -echo > /dev/tty
  read PASSWORD < /dev/tty; echo
  echo -n "Retype UNIX password: "
  read VERIFY < /dev/tty; echo
  if [ ${PASSWORD} != ${VERIFY} ]; then
	echo "Sorry, passwords do not match"
	stty echo > /dev/tty
	exit 1
  fi
  stty echo > /dev/tty
  PASSWORD=$(echo $PASSWORD | hashalot -x sha512)

  echo "$1:$PASSWORD"